package com.restaurant.springboot.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "comment", schema = "restaurant", catalog = "")
public class CommentEntity {

    private int id;
    private int userId;
    private String content;
    private int orderId;
    private int praise;

    private Timestamp time;

    public CommentEntity() {
    }

    public CommentEntity(int userId, String content, int orderId, int praise, Timestamp time) {
        this.userId = userId;
        this.content = content;
        this.orderId = orderId;
        this.praise = praise;
        this.time = time;
    }

    @Id
    @Column(name = "id")
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "user_id")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "content")
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Basic
    @Column(name = "order_id")
    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }


    @Basic
    @Column(name = "praise")
    public int getPraise() {
        return praise;
    }

    public void setPraise(int praise) {
        this.praise = praise;
    }

    @Basic
    @Column(name = "time")
    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CommentEntity that = (CommentEntity) o;
        return id == that.id &&
                userId == that.userId &&
                orderId == that.orderId &&
                praise == that.praise &&
                content.equals(that.content) &&
                time.equals(that.time);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userId, content, orderId, praise, time);
    }
}
